home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Online / SpeakFreely / src / codecs.c < prev    next >
C/C++ Source or Header  |  2000-05-18  |  826b  |  32 lines

  1. /*
  2.  
  3.          Sound encoder and decoder interfaces
  4.  
  5. */
  6.  
  7. #include "speakfree.h"
  8.  
  9. static struct adpcm_state adpcm;      /* ADPCM compression state */
  10.  
  11. /*  ADPCMDECOMP  --  Decompress the contents of a sound buffer using ADPCM.  */
  12.  
  13. void adpcmdecomp(sb)
  14.   struct soundbuf *sb;
  15. {
  16.     char *dp = (char *) sb->buffer.buffer_val;
  17.     unsigned char *sp;
  18.     unsigned char dob[TINY_PACKETS * 2];
  19.  
  20.     /* Restore the decoder state from the copy saved in the packet,
  21.        independent of the byte order of the machine we're running on. */
  22.  
  23.     sp = (unsigned char *) dp + (sb->buffer.buffer_len - 3);
  24.     adpcm.valprev = (sp[0] << 8) | sp[1];
  25.     adpcm.index = sp[2];
  26.     sb->buffer.buffer_len -= 3;
  27.  
  28.     adpcm_decoder_u(dp, dob, sb->buffer.buffer_len * 2, &adpcm);
  29.     sb->buffer.buffer_len *= 2;
  30.     bcopy(dob, dp, sb->buffer.buffer_len);
  31. }
  32.